package com.rtx.wms.customer.grp.upload.impl;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.rtx.edi.platform.field.service.PlFieldMappingService;
import com.rtx.wms.customer.grp.upload.GRPUploadService;
import com.rtx.wms.std.common.bean.WmsConstant;
import com.rtx.wms.std.so.bean.ApiOrdersfinish;

/**
 * 出库单回传
 */
@Primary
@Component("GrpOrderCallback")
public class GrpOrdersReturn extends GRPUploadService{

	Logger log = LoggerFactory.getLogger(this.getClass());
	
	@Autowired
	PlFieldMappingService plFieldMappingService;

	@Override
	protected String resolveCallBackAPICode(Object data) {
		return "GrpOrderCallback";
	}


	@Override
	protected void resolveResonse(String response, Object data) {
		
		super.resolveResonse(response, data);
		
		ApiOrdersfinish finish = (ApiOrdersfinish) data;
		try {
			JSONObject res = JSON.parseObject(response,JSONObject.class);
			String code = res.getString("code");
			if("200".equals(code)) {
				if("0".equals(finish.getRtxiscontainer())) {
					finish.setCallshipediflag(WmsConstant.DEFAULT_FLAG);
				}
			}
		} catch (Exception e) {
			log.error("",e);
		}
	}
	
	
}
